package cn.buddha.jec.exception;

import lombok.Getter;
import lombok.Setter;

/**
 * @ClassName TongPlatformException
 * @Author 友野浩二
 * @Description 平台级异常基类(存储异常码和异常消息)
 * @Version 1.0
 * <p>
 * Spring 对于 RuntimeException类的异常才会进行事务回滚，所以我们一般自定义异常都继承该异常类。
 */
@Setter
@Getter
public class TongPlatformException extends RuntimeException {

    private static final long serialVersionUID = -8252342484961827798L;

    private String exceptionCode;

    private String exceptionMessage;

    public TongPlatformException(String exceptionCode, String exceptionMessage) {
        // 在打印堆栈信息时会打印出来,示例：[{"exceptionCode":"123456", "exceptionMessage":"异常测试"}]
        super("[{\"exceptionCode\" : \"".concat(exceptionCode).concat("\", \"exceptionMessage\" : \"").concat(exceptionMessage).concat("\"}]"));
        this.exceptionCode = exceptionCode;
        this.exceptionMessage = exceptionMessage;
    }
}
